<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/m/include/init_mobile.jsp" %><%@ page import="com.qbooks.member.*" %>
<%
	MemberDAO dao = new MemberDAO();
	String member_id	= StringUtil.nvl(request.getParameter("id"));
	//String member_pw	= StringUtil.nvl(request.getParameter("pw"));
	
	
	HashMap infos = new HashMap();
	infos.put("member_id", member_id);
	//infos.put("member_pw", member_pw);
	infos.put("status", "1");


	
	if ("".equals(member_id)) {	
		//핸드폰이 로그인 안되어 있는 경우, 로그인화면으로 이동
		response.sendRedirect("/m/member/login.jsp?os="+os);
		return;
	}
	else {
		
		if (session_user_id.equals(member_id)) {	//이미 로그인되어 있는 경우
			//pass
		}
		else {	//로그인이 안되어 있거나 다른 사용자로 로그인하는 경우
			HashList info = dao.selectMemberList(infos);
			if (info.size() == 1) {
	    		session.setAttribute("session.user_id", info.get("member_id",0));
				session.setAttribute("session.user_name", info.get("member_name",0));
				session.setAttribute("session.user_auth", "GE");
			} else {	//로그인 실패
				session.invalidate();
				response.sendRedirect("/m/member/login.jsp?os="+os);
				return;
			}
		}
	}

%>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
	<title><%= HOME_NAME %></title>
	<%@ include file="/m/include/cssnjs.jsp"  %>
	<link rel="stylesheet" href="/css/jquery.mobile-1.4.2.min.css"/>
	<script type="text/javascript">
	$(document).ready(function() {
		$('#header-nav li:nth-child(4)').addClass('on');
	});
	

	function fnLogout() {

		$.ajax({
			url: '/member/logout.json',
			type: "POST",
		    dataType: 'json',
		    data:$('#frm').serialize(),
		    error: function(data, status, err){
		    	cfShowModal(err);
		    },
			success: function(data){
				<%	if (os.equals("android")) {	%>
						window.android.logoutSuccess();
				<%	} else if (os.equals("ios")) {	%>
						window.location="jscall:logoutSuccess:";
				<%	}	%>
		    }
		});
	}
	
	function fnGoMemberUpdate() {
		document.location.href = "./memberUpdate.jsp?os=<%=os%>";
	}
	
	function fnGoSalesList() {
		document.location.href = "./salesList.jsp?os=<%=os%>";
	}
	
	function fnGoDeviceList() {
		document.location.href = "./deviceList.jsp?os=<%=os%>";
	}

	function fnGoUseTerms() {
		document.location.href = "./useTerms.jsp?os=<%=os%>";
	}
	
	function fnGoPrivacy() {
		document.location.href = "./privacy.jsp?os=<%=os%>";
	}
	</script>
</head>
<body>
	<div id="wrap">
		<%@ include file="/m/include/header.jsp"  %>
		<div id="contents">
			
			<div id="login" class="ui-page-theme-a">
				<h3><%= member_id %></h3>
				큐북서점에서 구매하신 전자북은 동시에 최대 5개의 기기에서 로그인하여 사용하실 수 있습니다.
				<div class="ui-btn ui-input-btn ui-btn-active ui-corner-all ui-shadow">
					로그아웃<input type="button" alt="로그아웃" value="로그아웃" onclick="fnLogout()"/>
				</div>
				<!-- <div class="ui-btn ui-input-btn ui-corner-all ui-shadow">
					회원정보변경<input type="button" alt="회원정보변경" value="회원정보변경" onclick="fnGoMemberUpdate()"/>
				</div>
	        	<div class="ui-btn ui-input-btn ui-corner-all ui-shadow">
					구매내역<input type="button" alt="구매내역" value="구매내역" onclick="fnGoSalesList()"/>
				</div>
	        	<div class="ui-btn ui-input-btn ui-corner-all ui-shadow">
					디바이스관리<input type="button" alt="디바이스관리" value="디바이스관리" onclick="fnGoDeviceList()"/>
				</div>
	        	<div class="ui-btn ui-input-btn ui-corner-all ui-shadow">
					이용약관<input type="button" alt="이용약관" value="이용약관" onclick="fnGoUseTerms()"/>
				</div>
	        	<div class="ui-btn ui-input-btn ui-corner-all ui-shadow">
					개인정보취급방침<input type="button" alt="개인정보취급방침" value="개인정보취급방침" onclick="fnGoPrivacy()"/>
				</div> -->
			</div>
			

			<ul class="listview">
				<li class="group first">계정정보</li>
	        	<li><a href="./memberUpdate.jsp?os=<%=os%>&member_id=<%=session_user_id%>">회원정보변경</a></li>
	        	<li><a href="./salesList.jsp?os=<%=os%>&member_id=<%=session_user_id%>">구매내역</a></li>
				<li><a href="./deviceList.jsp?os=<%=os%>&member_id=<%=session_user_id%>">디바이스관리</a></li>
				<li><a href="./memberOut.jsp?os=<%=os%>&member_id=<%=session_user_id%>">회원탈퇴</a></li>
			</ul>
			<ul class="listview">
				<li class="group">이용안내</li>
				<li><a href="./useTerms.jsp?os=<%=os%>">이용약관</a></li>
				<li><a href="./privacy.jsp?os=<%=os%>">개인정보취급방침</a></li>
			</ul>
		</div>
		<%@ include file="/m/include/footer.jsp"  %>			
	</div>

</body>

</html>









